package cate.game.activity.weekcard.msg;

import cate.game.GameBody;
import cate.game.activity.weekcard.WeekCardActivity;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBWeekCardActivity;
import easy.java.dev.note.NoteField;
import easy.java.practice.errorcode.EcResult;

@ClientMsg(title = "领取周卡每日奖励的请求")
public class GetWeekCardDailyRewardReq implements MsgInput {
    @NoteField("功能ID")
    public int funcId;
    @NoteField("周卡配置ID")
    public int tid;
    @NoteField("第几天的奖励")
    public int day;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        WeekCardActivity weekCard= cc.getRole().getActivity().getEnableActivitySingle(funcId);
        if (weekCard == null) {
            cc.getRole().getGame().notice.message(cc.getRole(), "活动未开启");
            return;
        }
        EcResult<WeekCardActivity> r = weekCard.getReward(tid, day);
        if (r.ok()) {
            r.data.noticeUpdate();
        } else {
            game.notice.message(cc.getRole(), r.message);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBWeekCardActivity.GET_WEEK_CARD_DAILY_REWARD_REQ;
    }
}
